package org.jhub1.system.xmpp.log;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.jhub1.system.env.Env;

public  class LogAdapter{
	
	private static boolean initialize = false;

	@SuppressWarnings("rawtypes")
	private LogAdapter(Class name) {
		if(!initialize) {
			init();
			initialize = true;
		}
		logger = Logger.getLogger(name);
	}
		
	private LogAdapter(String name) {
		if(!initialize) {
			init();
			initialize = true;
		}
		logger = Logger.getLogger(name);
	}
	
	private Logger logger = null;

	@SuppressWarnings("rawtypes")
	public static LogAdapter getLog(Class name) {
		return new LogAdapter(name);
	}
	
	public static LogAdapter getLog(String name) {
		return new LogAdapter(name);
	}

	private static void init() {
		PropertyConfigurator
				.configure(Env.getLog4jConfig("/home/marek/workspaceJuno/JabberClient/src/JabberProxy_log4j.config"));
	}

	public void debug(String msg) {
		if (Env.isDebug()) {
			logger.debug(msg);
		}
	}

	public void info(String msg) {
		if (Env.isDebug()) {
			logger.info(msg);
		}
	}

	public void warn(String msg) {
		logger.warn(msg);
	}

	public void error(String msg) {
		logger.error(msg);
	}

	public void fatal(String msg) {
		logger.fatal(msg);
	}
	
//	StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace()
	//		The last element of the array represents the bottom of the stack, which is the least recent method invocation in the sequence. 		
			

}